define('boboweb/adminui/AdminUI',function(require,exports,module){
var returnObj={};
returnObj.extend=function(B){
//扩展--------------------------------start
	//等待一段时间执行一个方法。
	/**
	 * 后台组件封装
	 * @param {[type]} $templet 模板对象。
	 * 
	 */
	B.AdminUI=function(templet){
		var THIS=this;
		this.__classType='AdminUI';
		var _THIS=this;
		var _templet=templet;
		//自定义
		_templet['form']=$('<script><form class="pure-form pure-form-aligned" name="[:=id:]" id="[:=id:]" action="[:=url:]" method="[:=method:]"></script>');
		_templet['fieldset']=$('<script><fieldset></script>');
		_templet['panel']=$('<script><div class="boboadmin-ui-panel"><div class="header">[:=title:] <a id="searchBtn" class="pure-button button-xsmall margin-right-pub pull-right">关闭</a></div><div class="body"></script>');
		
			
			
		//console.log('adminui init..');
		//console.log('get templet:');
		//console.log(_templet['breadcrumb']);
		this.run=function($targetContainer,jsonData,location,ui,uiWait,uiWaitRemove){
			var data=null;
			try{
				data=$.parseJSON(jsonData);
				//console.log(data);
			}catch(e){
				console.log('data error!');
			}
			var endTag=[];
			var html='<div>';
			//console.log('form');
			//console.log(_templet['form']);
			var isInitWindowClick=false;
			var isRenderNumber=false;
			var isRenderDataTableManage=false;
			$.each(data,function(index,item){
				if('type' in item){
					var type=item.type;
					//console.log('-----');
					//console.log(type);
					//console.log(item);
					if(type in _templet||type=='end'){ //type
						if(type!='end'){
							//添加对应的结束标签,后面如果遇到end 会排队式的拿出来用
							if(type=='form') endTag.push('</form>');
							if(type=='fieldset') endTag.push('</fieldset>');
							if(type=='panel') endTag.push('</div></div>');
							//
							if(type=='number') isRenderNumber=true;
							if(type=='dataTableManage') isRenderDataTableManage=true;

							switch(type){
								case 'breadcrumb':
								case 'form':
								case 'tip':
								case 'text':
								case 'textpwd':
								case 'select':
								case 'checkbox':
								case 'radio':
								case 'switch':
								case 'number':
								case 'colorpicker':
								case 'datetime':
								case 'date':
								case 'time':
								case 'textarea':
								case 'editor':
								case 'upImgOne':
								case 'dataTableManage':
								case 'panel':
									//console.log(_templet[type].html());
									var temHtml=B.template(_templet[type].html(),item);
									//console.log(temHtml);
									html+=temHtml
									break;
							}
							//console.log(type);
							//console.log(html);
						}else{
							//console.log('endTem:'+endTag.length);
							if(endTag.length!=0){
								var endTem=endTag.pop();
								//console.log('endTem:'+endTem);
								html+=endTem;
							}

						}
					}
					//console.log(type);
				}
			});
			html+='</div>';
			//console.log('最终生成的html:');
			//console.log(html);
			var $htmlTem=$(html);
			$targetContainer.append($htmlTem);
			//-------------渲染js组件-----start
			if(isRenderNumber){
				B.getSeajsRequire().async('jqueryplug/spinner/jquery.spinner.min.js',function(){
					//console.log($htmlTem.find('.boboadmin-ui-number'));
					$htmlTem.find('.boboadmin-ui-number').spinner();
				});
			}
			if(isRenderDataTableManage){
				B.extendAsync('boboweb/DataTableManage.js',function(B){
					$htmlTem.find('.dataTableManage').each(function(index,item){
						var $item=$(item);
						var urlTem=$item.data('url');
						var dtm=B.DataTableManage(urlTem,_templet['dataTableManage_tpl'].html(),$item,location,ui,uiWait,uiWaitRemove);
					});//end $htmlTem.find
					
				});
			}
			return $htmlTem;
		}
	}
//扩展--------------------------------end
}//end returnObj.extend
return returnObj;
});